package com.geek.javase.ch18.videodemo.pattern.proxy.statics;

import java.util.concurrent.TimeUnit;

/*
 *@Date 2025/11/6
 *@Author wangpeng
 *@Description TODO
 */
public class BankLogService {
    //登录
    public void login(Long id,String pwd){
        System.out.println("日志开始追踪：The Method login begin with [" + id + "," + pwd + "]");
        long startTime1 = System.currentTimeMillis();
        try {
            TimeUnit.SECONDS.sleep(1);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        if(id.equals(1L) && pwd.equals("123")){
            System.out.println("登录成功");
            return;
        }
        System.out.println("登录失败！");
        long endTime1 = System.currentTimeMillis();
        System.out.println("日志结束追踪：The Method login end with，耗时：" + (endTime1 - startTime1) + "ms");
    }
    //注册
    public void register(Long id,String  name,String pwd){
        System.out.println("日志开始追踪：The Method register begin with [" + id + "," + pwd + "]");
        long startTime2 = System.currentTimeMillis();
        try {
            TimeUnit.SECONDS.sleep(1);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        if(id.equals(1L) && pwd.equals("123")){
            System.out.println("登录成功");
            return;
        }
        System.out.println("登录失败！");
        long endTime2 = System.currentTimeMillis();
        System.out.println("日志结束追踪：The Method register end with，耗时：" + (endTime2 - startTime2) + "ms");
    }
}
